package www.bplead.com.data;

import android.content.Context;
import android.content.SharedPreferences;

import www.bplead.com.constant.PrinterConstant;

/**
 * Created by wangyangzi on 2017/3/3.
 */

public class DeviceData {
    private Context mContext;
    private DeviceData(Context context){
        mContext = context;
    };

    private static DeviceData deviceData;

    public static DeviceData getInstance(Context context) {
        if(deviceData == null) {
            deviceData = new DeviceData(context);
        }
        return deviceData;
    }

    public void setPrinterDevice(String printerDevice) {
        SharedPreferences sharedPreferences =
                mContext.getSharedPreferences(PrinterConstant.PRINTER_DEVICE, Context.MODE_PRIVATE);
        sharedPreferences.edit().putString(PrinterConstant.PRINTER_DEVICE_KEY, printerDevice).commit();
    }

    public String getPrinterDevice() {
        SharedPreferences sharedPreferences =
                mContext.getSharedPreferences(PrinterConstant.PRINTER_DEVICE, Context.MODE_PRIVATE);
        String printerDevice = sharedPreferences.getString(PrinterConstant.PRINTER_DEVICE_KEY, null);
        return printerDevice;
    }
}
